import request from "@/utils/request";

/**
 * 发包列表分页查询
 */
export const contractList = data => {
  return request({
    url: "/crm/contractees/page",
    method: "post",
    data
  });
};
/**
 * 获取执行中合同列表
 */
export const getContractList = params => {
  return request({
    url: "/crm/build/task/getContractListAndCoreVolume",
    method: "get",
    params
  });
};
/**
 * 承包人
 */
export const getContractorList = (customerId, roleGroup) => {
  return request({
    url: `/crm/contractees/${customerId}/${roleGroup}`,
    method: "get"
  });
};

/**
 * 发包
 */
export const contractAdd = data => {
  return request({
    url: "/crm/contractees/add",
    method: "post",
    data
  });
};

/**
 * 提交申请 重新申请 编辑发包
 */
export const contractSubmit = (data, type) => {
  return request({
    url: "/crm/contractees/" + type,
    method: "post",
    data
  });
};

/**
 * 查询发包基础信息、附件
 */
export const contractorDetails = contracteesId => {
  return request({
    url: `/crm/contractees/${contracteesId}`,
    method: "get"
  });
};
/**
 * 删除发包
 */
export const deleteContract = data => {
  return request({
    url: "/crm/contractees/delete",
    method: "delete",
    data
  });
};

/**
 * 附件列表
 */
export const fileList = contracteesId => {
  return request({
    url: `/crm/contractees/file/${contracteesId}/list`,
    method: "get"
  });
};
/**
 * 上传附件
 */
export const uploadFile = data => {
  return request({
    url: "/crm/contractees/file/upload",
    method: "post",
    data
  });
};
/**
 * 删除附件
 */
export const deleteFile = contracteesFileId => {
  return request({
    url: `/crm/contractees/file/${contracteesFileId}`,
    method: "delete"
  });
};

/**
 * 查询缓存发包明细
 */
export const queryInfoList = data => {
  return request({
    url: "/crm/contractees/queryContracteesInfoList",
    method: "post",
    data
  });
};
/**
 * 查询发包明细
 */
export const queryInfoListV2 = data => {
  return request({
    url: "/crm/contractees/queryContracteesInfoListV2",
    method: "post",
    data
  });
};
/**
 * 查询付款计划
 */
export const paymentList = contracteesId => {
  return request({
    url: `/crm/contractees/${contracteesId}/payment-plans`,
    method: "get"
  });
};

/**
 * 查询启用状态的发包模板列表
 */
export const templateList = customerId => {
  return request({
    url: `/crm/contractees/template/enable-list/${customerId}`,
    method: "get"
  });
};
/**
 * 验收标准模块
 */
export const standardTemplateTree = () => {
  return request({
    url: "/crm/checkStandard/list",
    method: "get"
  });
};
/**
 * 流程配置-获取任务列表table数据
 */
export const taskList = (busTypeId, params = { status: 1 }) => {
  return request({
    url: `/crm/build/taskTemplate/getBuildStageTaskList/${busTypeId}`,
    method: "get",
    params
  });
};

/**
 * 设置付款计划
 */
export const paymentPlanAdd = data => {
  return request({
    url: "/crm/contractees/set-payment-plan",
    method: "post",
    data
  });
};
/**
 * 查询发包模板列表
 */
export const getTemplate = data => {
  return request({
    url: "/crm/contractees/queryCacheContracteesInfoList",
    method: "post",
    data
  });
};
/**
 * 保存临时发包项目
 */
export const saveContractees = data => {
  return request({
    url: "/crm/contractees/saveContracteesInfoList",
    method: "post",
    data
  });
};
/**
 * 获取辅助资金上限
 */
export const getMoneyLimit = contractId => {
  return request({
    url: `/crm/contractees/get-auxiliary-money-upper-limit/${contractId}`,
    method: "get"
  });
};
/**
 * 移除
 */
export const removeContractees = data => {
  return request({
    url: "/crm/contractees/removeContracteesInfoList",
    method: "post",
    data
  });
};
/**
 * 保存明细
 */
export const save = data => {
  return request({
    url: "/crm/contractees/detail/save",
    method: "post",
    data
  });
};
/**
 * 确认并发起申请
 */
export const submit = data => {
  return request({
    url: "/crm/contractees/detail/submit",
    method: "post",
    data
  });
};
/**
 * 查询发包基础信息、附件、付款计划、发包清单
 */
export const allInfo = customerId => {
  return request({
    url: `/crm/contractees/all-info/${customerId}`,
    method: "get"
  });
};
/**
 * 撤回申请
 */
export const cancelApproval = contracteesId => {
  return request({
    url: `/crm/contractees/${contracteesId}/cancel-approval`,
    method: "post"
  });
};
/**
 * 状态数量查询
 */
export const numbers = data => {
  return request({
    url: "/crm/contractees/numbers",
    method: "post",
    data
  });
};
